#include <cstdio>
#include <cctype>

#define state(x) bool x (int c)
typedef state((*StateFunction));


/*************************************/


unsigned int words;

state (start)
{
	words = 0;
	return isalpha(c);
}

state (searching)
{
	return isalpha(c);
}

state (word_found)
{
	++words;
	return isalpha(c);
}


/*************************************/

struct State
{
	StateFunction function;
	State *next[2];

	inline State * execute (int c) {
		return next[function(c)];
	}
};

extern State
	st_start,
	st_searching_word,
	st_word_found,
	st_completing_word;

State
	st_start = {start, {&st_searching_word, &st_word_found}},
	st_searching_word = {searching, {&st_searching_word, &st_word_found}},
	st_word_found = {word_found, {&st_searching_word, &st_completing_word}},
	st_completing_word = {searching, {&st_searching_word, &st_completing_word}};


/*************************************/


int main ()
{
	int c;
	State *s;

	c = '\0';

	while (c != EOF)
	{
		s = &st_start;
		do
		{
			c = getchar();
			s = s->execute(c);
		}
		while (c != '\n' && c != EOF);
		if (words)
			printf("%d\n", words);
	}

	return 0;
}